const { app, clipboard } = require('electron');
const { initSchedule } = require('./web/schedule/initSchedule');
const { initIPC } = require('./web/ipc/initIPC');
const { initShortCut } = require('./web/shortcut/initShortCut')
const { initTray } = require('./web/tray/initTray')
const { createMainWin } = require('./biz/winService/baseWinService/createMainWin')
const { createPanelWin } = require('./biz/winService/baseWinService/createPanelWin')

const EnvContext = require('./common/context/EnvContext');
const { initBroadcast } = require('./web/broadcast/initBroadcast');
const { initBasePlugin } = require('./biz/baseService/basePluginService/initBasePlugin')
const { initMouseEvent } = require('./web/mouseEvent/initMouseEvent');


const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
    app.quit()
}

app.on('ready', () => {
    createMainWin();
    createPanelWin();
});
app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
});
app.on('activate', () => {
    if (EnvContext.getInstance().getMainWin() === null) {
        createMainWin();
    }
    createPanelWin();

});

app.dock.hide();
app.whenReady().then(() => {
    initBasePlugin()
    // initMouseEvent()
    initShortCut()
    initIPC()
    initBroadcast()
    initTray()
    initSchedule()
    const notifier = require('node-notifier');
    // String
    notifier.notify('Message');

    // Object
    notifier.notify({
        title: 'My notification',
        message: 'Hello, there!',
        wait: true
    });
})
